/* VSCode风格 Rust Web IDE 样式 */
:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --bg-quaternary: #3e3e42;
    --text-primary: #cccccc;
    --text-secondary: #969696;
    --text-disabled: #6a6a6a;
    --accent-color: #007acc;
    --accent-hover: #1177bb;
    --border-color: #3e3e42;
    --error-color: #f44747;
    --success-color: #4EC9B0;
    --warning-color: #ffcc02;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 顶部栏 */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-section {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn:hover {
    background: var(--bg-quaternary);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
}

.btn-secondary:hover {
    background: #27ae60;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-info {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.btn-info:hover {
    background: #2980b9;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.username {
    font-weight: 600;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 48px;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-action {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1rem;
}

.sidebar-action:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 文件树 */
.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.file-tree-item {
    cursor: pointer;
    user-select: none;
}

.file-item-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 16px;
    transition: background 0.2s;
}

.file-item-content:hover {
    background: var(--bg-tertiary);
}

.file-item-content.active {
    background: var(--accent-color);
    color: white;
}

.file-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.file-name {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-tree-children {
    margin-left: 16px;
    display: none;
}

.file-tree-children.expanded {
    display: block;
}

/* 编辑器区域 */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.editor-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.editor-tab {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.editor-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.editor-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-color);
}

.tab-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    font-size: 0.8rem;
}

.tab-close:hover {
    background: var(--bg-quaternary);
    color: var(--text-primary);
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-toolbar {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-title {
    font-weight: 600;
    font-size: 0.9rem;
}

#editor {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

/* 终端区域 */
.terminal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-top: 1px solid var(--border-color);
}

.terminal-header {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.terminal-content {
    flex: 1;
    background: #1e1e1e;
    color: #00ff00;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-y: auto;
    white-space: pre-wrap;
}

.terminal-input-container {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

#terminal-input {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

/* 初始化相关样式 */
.initialization-info {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
}

.initialization-info ul {
    margin: 12px 0;
    padding-left: 20px;
}

.initialization-info li {
    margin: 6px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 进度条样式 */
.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

#initialization-percent {
    text-align: center;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 12px;
}

#initialization-message {
    text-align: center;
    margin: 12px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 右键菜单 */
.context-menu {
    display: none;
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    min-width: 160px;
    overflow: hidden;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: var(--accent-color);
    color: white;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item.danger {
    color: var(--error-color);
}

.context-menu-item.danger:hover {
    background: var(--error-color);
    color: white;
}

/* 消息提示 */
.message {
    position: fixed;
    top: 60px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    z-index: 1002;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.message.success {
    background: var(--success-color);
    color: white;
}

.message.error {
    background: var(--error-color);
    color: white;
}

.message.info {
    background: var(--accent-color);
    color: white;
}

.message.warning {
    background: var(--warning-color);
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 48px;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 280px;
    }
    
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.2rem;
        padding: 4px;
    }
    
    .editor-tabs {
        overflow-x: auto;
    }
    
    .editor-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
        padding: 20px;
    }
    
    .message {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-quaternary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 代码高亮 */
.code-keyword { color: #569cd6; }
.code-type { color: #4ec9b0; }
.code-string { color: #ce9178; }
.code-comment { color: #6a9955; }
.code-number { color: #b5cea8; }
.code-function { color: #dcdcaa; }
.code-macro { color: #c586c0; }

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 连接状态指示器 */
.connection-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.connection-status.connected {
    background-color: var(--success-color);
}

.connection-status.disconnected {
    background-color: var(--error-color);
}

.connection-status.connecting {
    background-color: var(--warning-color);
}